package com.unione.unione_base.view

import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.lifecycleScope
import androidx.viewbinding.ViewBinding
import com.unione.unione_base.util.StatusBarUtil
import kotlinx.coroutines.CoroutineScope
import java.lang.reflect.ParameterizedType

abstract class BaseActivity<VB:ViewBinding> :AppCompatActivity(){

    protected lateinit var binding: VB
    val mContext: Context
        get() = this

    val mLifecycleOwner: LifecycleOwner
        get() = this

    val scope: CoroutineScope
        get() = lifecycleScope


    @Suppress("UNCHECKED_CAST")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        initTopBar()
        init()
    }

    protected open fun isImmersiveTopBar(): Boolean {
        return true
    }

    protected open fun initTopBar() {
        if (isImmersiveTopBar()) {
            StatusBarUtil.immersive(this)
            StatusBarUtil.darkMode(this)
        }

    }

    abstract fun init()

}